#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
class BroadThread;
class QHostAddress;
class TcpThread;

class QThread;
class TcpDepthWorker;
class DeviceInfo;
class RgbCapture;
class RgbVideoWidget;
class DeepVideoWidget;
class AboutDialog;
class DepthDataProcessor;
class DepthCloudDataProcessor;
class TcpIrWorker;
class DepthIrDataProcessor;
class FTPClient;

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <QFuture>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

signals:
    void sendTcpData(QByteArray);

    void sendChangeIpAndPort(const QString& , quint16);

    void startPointCloudSignal();

    void sendRestartCommand();

    void sendInitGeneral();
private slots:
    void onTcpConnected();
    void onTcpDisconnected();
    void showDeviceInfo();
    void openRgbViewInfo();
    void openDeepViewInfo();
    void openPCDFile();
    void openAboutActionInfo();

    void on_startButton_clicked();

    void on_stopButton_clicked();
    void handleError(const QString& error);
    //void onDecoderStarted();
    void onDecoderStopped();
    void on_startPointCloud_clicked();

    void onSetRtspIpAddress(const QString& error);
    void on_saveConfigureBtn_clicked();

    void on_defaultBtn_clicked();

    void showDepthConnectStatus(bool status);
private:
    Ui::MainWindow *ui;
    DeviceInfo * deviceInfo;
    RgbVideoWidget* rgbViewWidget;
    //DeepVideoWidget* deepViewWidget;
    AboutDialog* aboutDialog;

    QString m_ipStr;
    quint16 m_port;

    pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloud;

    RgbCapture* rgbCapture;

    TcpDepthWorker* tcpDepthWorker;

    TcpIrWorker* tcpIrWorker;

    DepthDataProcessor* m_depthDataProcessor;
    QThread* m_processingThread;

    DepthCloudDataProcessor* depthCloudDataProcessor;
    QThread* processCloudThread;

    DepthIrDataProcessor* depthIrDataProcessor;
    QThread* processIrThread;

    void readAllNodeYamlConfig();
    void uploadAllNodeYaml();
    void manageUploadTask(QFuture<bool> future); // 添加声明
    void initChannelInfo();
    bool checkCloudRange();

    FTPClient* m_ftpClient;
};
#endif // MAINWINDOW_H
